#!usr/bin/env node

const Koa = require('koa');
const app = new Koa();
const log = console.log


app.use((ctx,next)=>{
  console.log(ctx.path)
  if(ctx.method === 'GET' && ctx.path === '/authors/'){
    log("得到漫画书列表");
    ctx.body = "查询漫画书";
  }
  if(ctx.method === 'POST' && /\/authors\/w/.test(ctx.path)){
    log("按作者名查询");
    ctx.body = "添加漫画书";
  }
  if(ctx.method === 'POST' && ctx.path === '/authors/'){
    log("添加新的漫画书作者");
    ctx.body="添加成功";
  }
  if(ctx.method === 'PUT' && /\/authors\/(\d)+$/.test(ctx.path)){
    log("修改某ID的漫画书作者名称");
    ctx.body = "修改成功";
  }
  if(ctx.methode === 'DELETE' && /\/atuhors\/(\d)+$/.test(ctx.path)){
    log("删除某ID的漫画书作者");
    ctx.body = "删除成功";
  }

})

app.listen(8080)
